//深拷贝

class Address implements Cloneable{
    String city;

    public Address(String city) {
        this.city = city;
    }

    public Address clone() throws CloneNotSupportedException {
        return  (Address) super.clone();
    }

}
class Person implements Cloneable{
    String name;
    int age;
    Address address;
    public Person(String name,int age,Address address) {
        this.name = name;
        this.age = age;
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Person clone() throws CloneNotSupportedException {
        Person person = (Person) super.clone();
         person.setAddress(address.clone());
        return person;
    }
}
public class Solution2 {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person = new Person("张三",18,new Address("武汉"));
        Person personCopy = person.clone();
        System.out.println(person.getAddress() == personCopy.getAddress());  //比较的是引用地址是否相同
    }
}
